package com.drcoffee.drcoffeemall.service.impl;

import com.drcoffee.drcoffeemall.entry.FAQ;
import com.drcoffee.drcoffeemall.mapper.FAQMapper;
import com.drcoffee.drcoffeemall.service.FAQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class FAQServiceImpl implements FAQService {
    @Autowired
    FAQMapper faqMapper;

    @Override
    public Map<String, Object> getFAQ(String language, Integer machine_id, String search) {
        Map<String, Object> resultMap = new HashMap<>();
        try {
            List<FAQ> faqList;
            faqList = faqMapper.getFAQ(language, machine_id, '%' + search + '%');
            resultMap.put("faqList", faqList);
        } catch (Exception e) {
            log.error("===================== uploadImage()异常： =====================", e);
            resultMap.put("reason", e.getMessage());
        }
        return resultMap;
    }

}
